/*
 * @Description: 消费者线程
 * @Author: rendc
 * @Date: 2024-10-12 15:40:52
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-12 15:51:38
 */
/**
 * Customer
 */
public class Customer extends Thread {
  // 属性
  private Clerk clerk;

  // 构造器
  public Customer() {
  }

  public Customer(Clerk clerk) {
    this.clerk = clerk;
  }

  @Override
  public void run() {
    System.out.println("消费者：" + getName() + "开始购买产品");
    while (true) {
      try {
        Thread.sleep(1000); // 每间隔1秒购买一个
      } catch (Exception e) {
        e.printStackTrace();
      }
      clerk.callCustomer();
    }
  }

}